/*
* Copyright 2011 Pavel Kozhin 
*
* Licensed under the Apache License, Version 2.0 (the "License"); 
* you may not use this file except in compliance with the License. 
* You may obtain a copy of the License at 
* 
* http://www.apache.org/licenses/LICENSE-2.0
* 
* Unless required by applicable law or agreed to in writing, software 
* distributed  under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
* See the License for the specific language governing permissions and 
* limitations under the License.
*
* Author: Pavel Kozhin.
*/
package org.etherframework.core
{
	import org.etherframework.core.common.IInstanceFactory;
	import org.etherframework.core.common.IObjectProcessor;
	import org.etherframework.core.common.SuperFactory;
	import org.etherframework.core.module.ModulePartFactory;

	// Shared modules config
	[ExcludeClass]
	public class GlobalConfig
	{
		private var _objectProcessors:Vector.<IObjectProcessor> = new Vector.<IObjectProcessor>();
		private var _instanceFactory:IInstanceFactory;
		private var _wiringFactory:ModulePartFactory;
		private var _commandsFactory:ModulePartFactory;
		private var _mediationFactory:ModulePartFactory;
		private var _dependenciesFactory:ModulePartFactory;
		private var _mediatorsFactory:ModulePartFactory;
		private var _superFactory:SuperFactory = new SuperFactory();
		
		public function get instanceFactory():IInstanceFactory { return _instanceFactory; }
		public function set instanceFactory(value:IInstanceFactory):void 
		{
			if (!_instanceFactory)
			{
				_instanceFactory = value;
			}
		}
		
		public function get mediatorsFactory():ModulePartFactory { return _mediatorsFactory; }
		public function set mediatorsFactory(value:ModulePartFactory):void 
		{
			if (!_mediatorsFactory)
			{
				_mediatorsFactory = value;
			}
		}
		
		public function get dependenciesFactory():ModulePartFactory { return _dependenciesFactory; }
		public function set dependenciesFactory(value:ModulePartFactory):void 
		{ 
			if (!_dependenciesFactory)
			{
				_dependenciesFactory = value;
			}
		}
		
		public function get commandsFactory():ModulePartFactory { return _commandsFactory; }
		public function set commandsFactory(value:ModulePartFactory):void 
		{
			if (!_commandsFactory)
			{
				_commandsFactory = value; 
			}
		}
		
		public function get wiringFactory():ModulePartFactory { return _wiringFactory; }
		public function set wiringFactory(value:ModulePartFactory):void 
		{
			if (!_wiringFactory)
			{
				_wiringFactory = value;
			}
		}
		
		public function get mediationFactory():ModulePartFactory { return _mediationFactory; }
		public function set mediationFactory(value:ModulePartFactory):void 
		{
			if (!_mediationFactory)
			{
				_mediationFactory = value; 
			}
		}
		
		public function addObjectProcessor(value:IObjectProcessor):void
		{
			_objectProcessors.push(value);
		}
		
		public function getObjectProcessors():Vector.<IObjectProcessor>
		{
			return _objectProcessors.concat();
		}
		
		public function get superFactory():SuperFactory { return _superFactory; }
		public function set superFactory(value:SuperFactory):void 
		{
			if (!_superFactory)
			{
				_superFactory = value;
			}
		}
	}
}